<template>
  <div>
    <el-form-item
      :label="parentNoTitle"
      label-width="150px"
      class="normal-type"
      v-if="$store.state.edit.row.level != 1"
    >
      <div slot="label">
        <span style="color:red">*</span>{{ parentNoTitle }}
      </div>
      <el-select
        style="width: 80%"
        v-model="$store.state.edit.row.parentNo"
        filterable
        default-first-option
        clearable
        :placeholder="placeholder"
        :remote="row.search"
      >
        <el-option
          v-for="(label,value) in $store.state.edit.entry.sources['amoebaParentNoAllSource ' + ($store.state.edit.row.level)]"
          :key="value"
          :label="label"
          :value="value"
        >
        </el-option>
      </el-select>
    </el-form-item>
  </div>
</template>

<script>
  import {m, notify} from "@/store/yg/common/local";
  import {ajax} from "@/store/yg/common/utils";
  import axios from "axios";
  import * as constant from "@/store/yg/common/constant";

  export default {
    data() {
      return {
        parentNoTitle: "",
        placeholder: "",
        row: {},
        loadingPort: [{required: true, message: "必填", trigger: "change"}]
      };
    },
    beforeCreate() {

    },
    created() {
      this.row = this.$store.state.edit.row;
      this.placeholder = m("please_select");
      this.parentNoTitle = m("subject_parent_no");
      this.initParentNoData();

    },

    methods: {
      initParentNoData() {
        var level = this.row.level;
        this.$store.dispatch("loadEditOptionSource", {
          bean: "amoebaParentNoAllSource",
          arg: level,
          cached: false,
          dependency: true
        });
      },

      callvalidate() {
        console.log("this.$store.state.edit.row", this.$store.state.edit.row)
        if (
          (this.$store.state.edit.row["parentNo"] == "" || this.$store.state.edit.row["parentNo"] == null) &&
          this.$store.state.edit.row["level"] != 1
        ) {
          notify({
            message: m("field") + ": parentNo " + m("required"),
            type: "error",
            duration: 10000,
            dangerouslyUseHTMLString: true,
            position: "bottom-right"
          });
          return false;
        }

        return true;
      },
      callbefore() {
      }
    }
  };
</script>

<style>
  .mail {
    text-align: left;
  }

  .normal-type .el-form-item__content {
    padding: 0 5px 0 15px;
  }
</style>
